<?php

namespace App\Admin\Actions\Grid\Withdraw;

use App\Admin\Forms\User\AllocateWalletForm;
use App\Admin\Forms\Withdraw\SendTxForm;
use Dcat\Admin\Actions\Response;
use Dcat\Admin\Grid\RowAction;
use Dcat\Admin\Traits\HasPermissions;
use Dcat\Admin\Widgets\Modal;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;

class SendTx extends RowAction
{
    /**
     * @return string
     */
    protected $title = '审核下发';


    public function getConfirmContent()
    {
        return "确认操作";
    }

    public function render()
    {
        $form = SendTxForm::make()->payload(['id' => $this->getKey(),  'chain' => $this->row->chain]);
        return Modal::make()
            ->lg()
            ->body($form)
            ->button($this->title);
    }

    /**
     * Handle the action request.
     *
     * @param Request $request
     *
     * @return Response
     */
    public function handle(Request $request)
    {
    }

    public function success()
    {
        return $this->response()
            ->success('操作成功: ' . $this->getKey())
            ->redirect('/user');
    }

    public function fail()
    {
        return $this->response()
            ->error('操作失败: ' . $this->getKey())
            ->redirect('/user');
    }

    /**
     * @return string|array|void
     */
    public function confirm()
    {
        return [$this->getConfirmContent(), '弹窗内容'];
    }

    /**
     * @param Model|Authenticatable|HasPermissions|null $user
     *
     * @return bool
     */
    protected function authorize($user): bool
    {
        return true;
    }

    /**
     * @return array
     */
    protected function parameters()
    {
        return [];
    }

}
